package com.tengju.bff.interfaces.shared;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * @author chenhang
 * @Date 2021/3/6
 */
@Data
@ApiModel(value = "KVVO", description = "键值对象")
public class KVVO<L, V> {

    @ApiModelProperty(value = "标题")
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    L label;

    @ApiModelProperty(value = "内容")
    V value;

    @ApiModelProperty(value = "额外信息")
    Object extra;


    String AMOUNT_TYPE = "KV";
    L AMOUNT_TITLE;

    public static <L, V> KVVO<L, V> of(L label, V value) {
        return new KVVO<>(label, value);
    }

    public static <L, V> KVVO<L, V> of(L label, V value, Object extra) {
        return new KVVO<>(label, value, extra);
    }

    private KVVO() {
    }

    private KVVO(L label, V value) {
        this.label = label;
        this.value = value;
        this.AMOUNT_TITLE = label;
    }

    private KVVO(L label, V value, Object extra) {
        this.label = label;
        this.value = value;
        this.extra = extra;
        this.AMOUNT_TITLE = label;
    }

}
